package core.util;

import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Shell;

public class DialogPositioner {
	public static void centerShell(Shell childShell) {
		Shell parentShell = childShell.getParent().getShell();

		Rectangle parentShellBounds = parentShell.getBounds();

		Point childDialogSize = childShell.getSize();

		childShell.setLocation(parentShellBounds.x + (parentShellBounds.width - childDialogSize.x) / 2, parentShellBounds.y + (parentShellBounds.height - childDialogSize.y) / 2);
	}
}
